<%@ page language="java" import="java.util.*" pageEncoding="utf8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html>
<html>
  <head>
    <title>添加快递单</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<style type="text/css">
		
	</style>
	<script type="text/javascript" src="js/jquery-latest.js"></script>
	<script type="text/javascript">
		function change() {
			var taobao_copy_address = $( "#taobao_copy_address" ).val();
			
  			var str = new Array();   
  			
  			//  	杨柳 ，13510600219 ， ，广东省 深圳市 罗湖区 红桂路 宝泉庄 1008号 4栋1单元402 ，518002 
  
  			str = taobao_copy_address.split( " ，" );
  			
  			var receiver_name = str[0];
  			var receiver_mobile = str[1];
  			var receiver_phone = str[2];
  			var receiver_adress = str[3];
  			var post_code = str[4];
  			var destinationCity = receiver_adress.split(" ")[1];
  			receiver_adress = filterSpace(receiver_adress);
  			var receiver_zip = str[4];
  			
  			$( "#receiver_name" ).attr( "value", receiver_name );
  			$( "#receiver_mobile" ).attr( "value",  receiver_mobile);
  			$( "#receiver_phone" ).attr( "value", receiver_phone );
  			$( "#destinationCity" ).attr( "value", destinationCity );
  			$( "#receiver_adress" ).attr( "value", receiver_adress );
  			$( "#receiver_zip" ).attr( "value", receiver_zip );
  			
  			//alert( str[1]);	
		}
		
		/**
		 * 过滤字符串中间的空格
		 * @param str
		 * 			要过滤的字符串
		 * @returns
		 * 			过滤好的字符串
		 */
		function filterSpace(str) {
			var array = str.split(" ");
			
			var str = "";
			for(var i in array) {
				str += array[i];
			}
			return $.trim(str);
		}
	</script>
  </head>
  
  <body>
  <s:debug>
  <s:form action="/express/printExpress.action">
  	<div>
  		地址: 
  		<input type="text" id="taobao_copy_address" style="margin-top: 10px" /> 
  		<input type="button" value="生成" onclick="change()" /> <br>
  		请选择快递公司:   
		<s:select 
			name="expressCode"
			list="#session.expressList"
			listValue="name"
			listKey="name"
	    />
  	</div>
	<table border="1" width="1080">
		<tr>
			<td>
				寄件人姓名:
				<s:textfield name="expressPage.senderName" value="%{#session.expressPage.senderName}" />
			</td>
			<td>
				始发地:
				<s:textfield name="expressPage.originCity" value="%{#session.expressPage.originCity}"/>
			</td>
			<td>
				收件人姓名:
				<s:textfield id="receiver_name" name="expressPage.receiverName" />
			</td>
			<td>
				目的地:
				<s:textfield name="expressPage.destinationCity" id="destinationCity" />
			</td>
		</tr>
		
		<tr>
			<td colspan="2">
				单位名称:
				<s:textfield name="expressPage.senderCompany" size="50" value="%{#session.expressPage.senderCompany}"/>
			</td>
			<td colspan="2">
				单位名称:
				<s:textfield name="expressPage.receiverCompany" size="50" />
			</td>
		</tr>
		
		<tr>
			<td colspan="2">
				寄件地址1:
				<s:textfield name="expressPage.senderAddress1" size="55" value="%{#session.expressPage.senderAddress1}"/>
			</td>
			<td colspan="2">
				收件地址1:
				<s:textfield id="receiver_adress" name="expressPage.receiverAddress" size="55" />
			</td>
		</tr>
		
		<tr>
			<td colspan="4">
				寄件地址2:
				<s:textfield name="expressPage.senderAddress2" size="55" value="%{#session.expressPage.senderAddress2}" />
			</td>
		</tr>
		
		<tr>
			<td colspan="2">
				联系电话:
				<s:textfield name="expressPage.senderPhone" size="55" value="%{#session.expressPage.senderPhone}" />
			</td>
			<td colspan="2">
				联系电话:
				<s:textfield id="receiver_mobile" name="expressPage.receiverPhone" size="55" />
			</td>
		</tr>
		
		<tr>
			<td colspan="2">
				内件品名:
				<s:textfield name="expressPage.sellGoodsName" value="%{#session.expressPage.sellGoodsName}" />
			</td>
			<td colspan="2">
				备注:
				<s:textfield name="expressPage.descs" value="%{#session.expressPage.descs}" size="60"/>
			</td>
		</tr>
		
		<tr>
			<td colspan="4">
				年:
				<s:textfield name="expressPage.year" value="%{#session.expressPage.year}" size="5" />
				&nbsp;&nbsp;
				月:
				<s:textfield name="expressPage.month" value="%{#session.expressPage.month}" size="3" />
				&nbsp;&nbsp;
				日:
				<s:textfield name="expressPage.day" value="%{#session.expressPage.day}" size="3" />
				&nbsp;&nbsp;
				签名:
				<s:textfield name="expressPage.senderSign" size="6" />
			</td>
		</tr>
		
	</table>
  	<s:submit value="打印" />
  </s:form>
  </s:debug>
  </body>
</html>
